/**
 * 
 */
package de.cbf.cam.dsa.tavern.carte.model.entities;

import java.beans.PropertyChangeSupport;

import de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.INamedEntity;

/**
 * @author Stefan Alter
 *
 */
public class Addendum implements Cloneable,INamedEntity{
	public static final int PCE_INDEX_name				= 2;
	public static final int PCE_INDEX_basePrice			= 3;
	public static final int PCE_INDEX_modifiedPrice		= 4;
	public static final int PCE_INDEX_description 		= 5;
	
	public final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
	
	protected String			 	name 					= "<Neue Zutat>";
	protected String 				description				= "<Beschreibung>";
	
	protected Double 			 	basePrice 				= 0.0d;
	protected Double				modifiedPrice			= 0.0d;
		
	@Override
	public String toString() {		
		return name;
	}
	@Override
	public Addendum clone() throws CloneNotSupportedException {
		Addendum clone = new Addendum();
		clone.name 			= name;
		clone.description 	= description;
		clone.basePrice 	= basePrice;
		clone.modifiedPrice = modifiedPrice;
		return clone;
	}
	
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((basePrice == null) ? 0 : basePrice.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result
				+ ((modifiedPrice == null) ? 0 : modifiedPrice.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Addendum other = (Addendum) obj;
		if (basePrice == null) {
			if (other.basePrice != null)
				return false;
		} else if (!basePrice.equals(other.basePrice))
			return false;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (modifiedPrice == null) {
			if (other.modifiedPrice != null)
				return false;
		} else if (!modifiedPrice.equals(other.modifiedPrice))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	public String getName() {
		return name;
	}
	public void setName(String value) {
		if(this.name.equals(value)) return;
		String oldName = this.name;
		this.name = value;
		propertyChangeSupport.fireIndexedPropertyChange("name",PCE_INDEX_name, oldName, value);		
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String value) {
		if(this.description.equals(value)) return;
		String oldDescription = this.description;
		this.description = value;
		propertyChangeSupport.fireIndexedPropertyChange("description",PCE_INDEX_description, oldDescription, value);		
	}
	
	public Double getBasePrice() {
		return basePrice;
	}
	public void setBasePrice(Double basePrice) {
		if(this.basePrice.equals(basePrice)) return;
		Double basePriceOld = this.basePrice;
		this.basePrice = basePrice;
		propertyChangeSupport.fireIndexedPropertyChange("basePrice",PCE_INDEX_basePrice, basePriceOld,basePrice);
	}
	public Double getModifiedPrice() {
		return modifiedPrice;
	}
	public void setModifiedPrice(Double modifiedPrice) {
		if(this.modifiedPrice.equals(modifiedPrice)) return;
		Double modifiedPriceOld = this.modifiedPrice;
		this.modifiedPrice = modifiedPrice;
		propertyChangeSupport.fireIndexedPropertyChange("modifiedPrice",PCE_INDEX_modifiedPrice, modifiedPriceOld,modifiedPrice);
	}

	
}
